﻿using Cysharp.Threading.Tasks;
using ShawnFramework;
using UnityEngine.UI;

public class LoadingPanel : Panel
{
    public Image imgProgress = null;

    private static bool Lock = false;
    /// <summary>
    /// 更新进度条
    /// </summary>
    /// <param name="progress"></param>
    /// <param name="duration"></param>
    public async UniTask UpdateProgress(float progress, float duration = 0.5f)
    {
        if (Lock) return;

        Lock = true;
        imgProgress.Active(true);
        await imgProgress.ProgressTo2(progress, duration);
        Lock = false;

        if (imgProgress.fillAmount >= 1.0f)
        {
            Close();
        }
    }
}